package com.zp.datax.core.function;

import java.util.function.BiFunction;
import java.util.function.Function;

/**
 * Created by bruce on 2018/12/18.
 */
@FunctionalInterface
public interface BiFunctionWrapper<T, U, R, E extends Exception> {

    R apply(T t, U u) throws E;

    default <V> BiFunction<T, U, V> andThen(Function<? super R, ? extends V> after) {
        return (t, u) -> {
            try {
                return after.apply(apply(t, u));
            } catch (Exception e) {
                throw new FunctionException(e);
            }
        };
    }
}
